﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using HF.Framework.DataClientDBAgent;
using HF.WorkFlow.Template;
using HF.WorkFlow.Engine;

public partial class UserControls_WorkflowMsgHead : System.Web.UI.UserControl
{
    string UserId = "";
    string workflowId = "";
    string worktaskId = "";
    protected void Page_Load(object sender, EventArgs e)
    {
        UserId = this.Page.User.Identity.Name;
        if (!this.IsPostBack)
        {
            InitData();
            
        }
        

    }
    private void InitData()
    {
        if (Request["workflowId"] != null && Request["worktaskId"] != null)
        {
            workflowId = Request["workflowId"].ToString();
            worktaskId = Request["worktaskId"].ToString();
            DataTable dt = WorkTask.GetInstance().GetWorkTaskView(worktaskId);
            if (dt != null && dt.Rows.Count > 0)
            {
                lbWorkflowCaption.Text = dt.Rows[0]["FlowCaption"].ToString();
                lbStartTaskCaption.Text = dt.Rows[0]["TaskCaption"].ToString();
            }
        }
        if (Request["WorkTaskInstanceId"] != null)
        {
            string workTaskInstanceId = Request["WorkTaskInstanceId"].ToString();
            DataTable dt = WorkTaskInstance.GetInstance().GetWorkTaskInstanceView(workTaskInstanceId);
            if (dt != null && dt.Rows.Count > 0)
            {
                lbWorkflowCaption.Text = dt.Rows[0]["FlowCaption"].ToString();
                lbStartTaskCaption.Text = dt.Rows[0]["TaskCaption"].ToString();
            }
        }
    }


    protected void btnStartWorkflow_Click(object sender, EventArgs e)
    {
        //WorkFlowRuntime wfruntime = new WorkFlowRuntime();
        //wfruntime.UserId = UserId;
        //wfruntime.WorkFlowId = tbxWorkflowId.Text;
        //wfruntime.WorkTaskId = tbxWorktaskId.Text;
        //wfruntime.WorkFlowInstanceId = Guid.NewGuid().ToString();
        //wfruntime.WorkTaskInstanceId = Guid.NewGuid().ToString(); ;
        //wfruntime.WorkFlowNo = "flow001";
        //wfruntime.CommandName = "提交";
        //wfruntime.WorkflowInsCaption = tbxWorkflowCaption.Text;
        //wfruntime.Start();

    }
}
